package com.example.demo.Controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")//设置路由地址，强烈建议全小写，不要搞大小写
public class UserController {

    @Value("${server.port}")//读取配置文件 一定要加${}
    private Integer port;

    //配置文件中的 单引号，双引号区别
    @Value("${mystring}")
    private String mystring;

    @Value("${mystring1}")
    private String mystring1;

    @Value("${mystring2}")
    private String mystring2;

    //将Student对象注入
    @Autowired
    private Student student;

    //读取集合
    @Autowired
    private ListConfig listConfig;


    @ResponseBody// 返回一个非静态页面的数据
    @RequestMapping("/sayhi")
    public String Sayhi() {
        return "Hellogood spring boot" + " " + "端口号为：" + port;
    }

    @ResponseBody// 返回一个非静态页面的数据
    @RequestMapping("/sayhi1")
    public void Sayhi1() {
        System.out.println("mystring" + mystring);
        System.out.println("mystring1" + mystring1);
        System.out.println("mystring2" + mystring2);
    }

    @ResponseBody// 返回一个非静态页面的数据
    @RequestMapping("/sayhi2")
    public Student Sayhi2() {
        return student;
    }

    @ResponseBody// 返回一个非静态页面的数据
    @RequestMapping("/sayhi3")
    public void Sayhi3() {
        //return listConfig;
        System.out.println(listConfig.getName());
    }
}
